//
//  JournalListCell.m
//  DataStatistics
//
//  Created by Kang on 16/4/14.
//  Copyright © 2016年 YTYangK. All rights reserved.
//

#import "JournalListCell.h"


@interface JournalListCell ()

@property (strong, nonatomic) IBOutlet UILabel *JLCell_workId;
@property (strong, nonatomic) IBOutlet UILabel *JLCell_workDate;
@property (strong, nonatomic) IBOutlet UILabel *JLCell_workFlow;
@property (weak, nonatomic) IBOutlet UILabel *JLCell_workbody;


@end

@implementation JournalListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark - 设置Cell UI及数据更新
- (void)vlueWithList:(JouList *)list {
    //名字
    self.JLCell_workId.text = list.employee_name;
    
    //报警时间
    NSTimeInterval time = list.beginAt / 1000;  //[NSString stringWithFormat:@"%f",list.beginAt/1000];
    
    
    if (list.scheduleNO==1) {
        
        NSMutableAttributedString *promptLanguageMut = [[NSMutableAttributedString alloc]initWithString:@"第一班"];
        // 设置 上面标题
        [promptLanguageMut addAttribute:NSForegroundColorAttributeName value:[UIColor grayColor] range:NSMakeRange(0, 3)];
        self.JLCell_workDate.attributedText = promptLanguageMut;
    }else if (list.scheduleNO ==2){
        NSMutableAttributedString *promptLanguageMut = [[NSMutableAttributedString alloc]initWithString:@"第二班"];
        // 设置 上面标题
        [promptLanguageMut addAttribute:NSForegroundColorAttributeName value:[UIColor grayColor] range:NSMakeRange(0, 3)];
        self.JLCell_workDate.attributedText = promptLanguageMut;
    }else if (list.scheduleNO ==3){
        NSMutableAttributedString *promptLanguageMut = [[NSMutableAttributedString alloc]initWithString:@"第三班"];
        // 设置 上面标题
        [promptLanguageMut addAttribute:NSForegroundColorAttributeName value:[UIColor grayColor] range:NSMakeRange(0, 3)];
        self.JLCell_workDate.attributedText = promptLanguageMut;
    }else if (list.scheduleNO ==4){
        NSMutableAttributedString *promptLanguageMut = [[NSMutableAttributedString alloc]initWithString:@"第四班"];
        // 设置 上面标题
        [promptLanguageMut addAttribute:NSForegroundColorAttributeName value:[UIColor grayColor] range:NSMakeRange(0, 3)];
        self.JLCell_workDate.attributedText = promptLanguageMut;
    }
    
    
    NSDate *detaildate=[NSDate dateWithTimeIntervalSince1970:time];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"MM/dd HH:mm"];
    NSString *currentDateStr = [dateFormatter stringFromDate: detaildate];
    self.JLCell_workFlow.text = currentDateStr;

    
    if (list.status == 1) {
        self.JLCell_workbody.text = @"报警时间";
            }else{
            self.JLCell_workbody.text = @"断开时间";
    }

}

//设置头像回调 - 没用的方法
+ (void)obtainHeadImage:(NSString *)imagerStr  return:(void (^) (NSData *vlue))vlue{
    if (imagerStr !=  nil && ![imagerStr isEqualToString:@""]) {
        NSURL *url = [NSURL URLWithString:[GET_HEND_IMAGE_IP stringByAppendingString:imagerStr]];
        
        dispatch_queue_t imagaQueue = dispatch_queue_create("ImageQueue", NULL);
        dispatch_async(imagaQueue, ^{
            if ([NSData dataWithContentsOfURL:url options:0 error:NULL]) {
                  NSData *imageData = [NSData dataWithContentsOfURL:url options:0 error:NULL];
                if (imageData) {
                   // [[NSUserDefaults standardUserDefaults] setObject:imageData forKey:@"headImage"];
                    vlue(imageData);
                }
            }
         });
        
    }
}

@end
